<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Korisnici</title>
        <h:outputStylesheet library="css" name="styles.css"/> 
    </h:head>
    <h:body>
        <ui:include src="adminMenuBar.xhtml"/>
        <ui:param name="s" value="student"/>
        <ui:param name="a" value="admin"/>
        <ui:param name="z" value="zaposleni"/>
        <h:form>
            <p:panel header="Korisnici" styleClass="headerPanel">
                <p:fieldset  legend="Dodaj korisnika" toggleable="true" toggleSpeed="500" collapsed="true">
                    <p:panel id="korisnik">
                        <h:panelGrid columns="2">
                            <p:outputLabel value="Tip: " />
                            <p:selectOneMenu value="#{adminBean.selectedRole}">
                                <f:selectItems value="#{adminBean.role}"/>
                                <p:ajax event="change" update="korisnik"/>
                            </p:selectOneMenu>
                        </h:panelGrid>
                        <h:panelGrid columns="2" >

                            <h:outputLabel value="Korisnicko ime:"/>
                            <p:inputText value="#{adminBean.newK.korisnickoIme}"/>

                            <h:outputLabel value="Sifra: "/>
                            <p:inputText value="#{adminBean.newK.lozinka}"/>

                            <h:outputLabel value=""/>
                            <p:commandButton value="Dodaj" action="#{adminBean.addUser()}" ajax="false" style="margin: auto;" rendered="#{adminBean.selectedRole.equals(a)}"/>


                        </h:panelGrid>
                        <h:panelGrid id="korinik1" columns="2" rendered="#{adminBean.selectedRole.equals(s)}">

                            <h:outputLabel value="Ime :"/>
                            <p:inputText value="#{adminBean.student.ime}"/>

                            <h:outputLabel value="Prezime :"/>
                            <p:inputText value="#{adminBean.student.prezime}"/>

                            <h:outputLabel value="Indeks :"/>
                            <p:inputMask value="#{adminBean.student.indeks}" mask="999/9999"/>

                            <h:outputLabel value="Telefon :"/>
                            <p:inputText value="#{adminBean.student.telefon}"/>

                            <h:outputLabel value="Adresa :"/>
                            <p:inputText value="#{adminBean.student.adresa}"/>
                            <h:outputLabel/>
                            <p:commandButton value="Dodaj" action="#{adminBean.addUser()}" ajax="false" style="margin: auto;"/>

                        </h:panelGrid>
                        <h:panelGrid id="korisnik2" columns="2" rendered="#{adminBean.selectedRole.equals(z)}">
                            <h:panelGrid columns="2">
                                <h:outputLabel value="Ime :"/>
                                <p:inputText value="#{adminBean.prof.ime}"/>

                                <h:outputLabel value="Prezime :"/>
                                <p:inputText value="#{adminBean.prof.prezime}"/>

                                <h:outputLabel value="Kabinet :"/>
                                <p:inputText value="#{adminBean.prof.kabinet}"/>

                                <h:outputLabel value="Prijem :"/>
                                <p:inputText value="#{adminBean.prof.prijem}"/>

                                <h:outputLabel value="Zvanje :"/>
                                <p:inputText value="#{adminBean.prof.zvanje}"/>

                                <h:outputLabel value="Status :"/>
                                <p:inputText value="#{adminBean.prof.status}"/>

                                <h:outputLabel value="Telefon :"/>
                                <p:inputText value="#{adminBean.prof.telefon}"/>

                                <h:outputLabel value="Web :"/>
                                <p:inputText value="#{adminBean.prof.web}"/>

                                <h:outputLabel value="Adresa :"/>
                                <p:inputText value="#{adminBean.prof.adresa}"/>

                                <h:outputLabel value="E-mail :"/>
                                <p:inputText value="#{adminBean.prof.mail}"/>

                                <h:outputLabel value="Istek ugovora :"/>
                                <p:inputText value="#{adminBean.prof.istekUgovora}"/>

                                <h:outputLabel value="Slika :"/>
                                <p:fileUpload mode="simple"/> 
                            </h:panelGrid>
                            <p:panel>
                                <h:outputLabel value="CV :"/>
                                <br/>
                                <br/>
                                <p:editor value="#{adminBean.prof.cv}" width="600" />
                            </p:panel>

                            <h:outputLabel/>
                            <p:commandButton value="Dodaj" action="#{adminBean.addUser()}" ajax="false" style="margin: auto;"/>
                        </h:panelGrid>
                    </p:panel>
                </p:fieldset>
                <p:panel header="Svi korisnici" >
                    <p:dataTable id="tabelaKorisnika" value="#{adminBean.korisnici}" var="k">
                        <p:column headerText="Ime" sortBy="ime">
                            <h:outputLabel value="#{k.korisnickoIme}"/>
                        </p:column>
                        <p:column headerText="Rola" >
                            <h:outputLabel value="#{k.role.description}"/>
                        </p:column>

                        <p:column headerText="Akcije">
                            <p:commandButton  icon="ui-icon-trash" ajax="false"/>
                            <p:commandButton  icon="ui-icon-trash" ajax="false"/>
                        </p:column>
                    </p:dataTable>
                </p:panel>
            </p:panel>
        </h:form>
    </h:body>
</html>
